
// 设备分组
import qs from 'qs'
import request from "@/utils/request"
import { getAesString } from '@/utils/aesUtil'

/**
 *GET 获取验证码
  * @params
 */
export function getCaptchaAPi() {
  return request({
    url: "/getCaptcha",
    method: "get"
  });
}


/**
 *GET 获取登录用户信息
  * @params
 */
export function getLoginUserAPi() {
  return request({
    url: "/getLoginUser",
    method: "get",
  })
}
/**
 *GET 退出登录
  * @params
 */
export function logoutAPi() {
  return request({
    url: "/user/logout",
    method: "get",
  })
}


/**
 * 用户登录
 * @params {
 "username": "string",
  "password": "string",
  "validateCodeKey": "string",
  "validateCode": "string"
}
 * @return {*}
 */
export function loginAPi(data) {
  const aesString = getAesString(
    JSON.stringify(data),
    'hj7x89H$yuBI0456',
    'NIfb&95GUY86Gfgh'
  )
  const postData = { ciphertext: aesString }
  return request({
    url: "/user/login",
    method: "post",
    data: postData,
  })
}

/**
 * 刷新Token
 * @params {
  "refreshToken": "string"
}
 * @return {*}
 */
export function refreshTokenAPi(data) {
  return request({
    url: "/user/refreshToken",
    method: "post",
    data
  })
}

/**
 * 切换租户
 * @params {
  "refreshToken": "string",
  "changeTenantId": 0
}
 * @return {*}
 */
export function changeTenantTokenAPi(data) {
  return request({
    url: "/user/changeTenantToken",
    method: "post",
    data
  })
}
/**
 * 修改密码
 * @params {
  "id": 0,
  "oldPassword": "string",
  "password": "string"
}
 * @return {*}
 */
export function modifyPasswordAPi(data) {
  return request({
    url: "/user/modifyPassword",
    method: "post",
    data
  })
}
